/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.ylystudio.pms.ejb.entity;

import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;

/**
 *
 * @author Kenny Lin
 */
@Entity
@Table(name = "knowledge")
@NamedQueries({
    @NamedQuery(name = "Knowledge.findAll", query = "SELECT k FROM Knowledge k"),
    @NamedQuery(name = "Knowledge.findByKnowledgeId", query = "SELECT k FROM Knowledge k WHERE k.knowledgeId = :knowledgeId"),
    @NamedQuery(name = "Knowledge.findByKnowledgeDate", query = "SELECT k FROM Knowledge k WHERE k.knowledgeDate = :knowledgeDate"),
    @NamedQuery(name = "Knowledge.findByKnowledgeVersion", query = "SELECT k FROM Knowledge k WHERE k.knowledgeVersion = :knowledgeVersion"),
    @NamedQuery(name = "Knowledge.findByKnowledgeContent", query = "SELECT k FROM Knowledge k WHERE k.knowledgeContent = :knowledgeContent"),
    @NamedQuery(name = "Knowledge.findByKnowledgeDisplay", query = "SELECT k FROM Knowledge k WHERE k.knowledgeDisplay = :knowledgeDisplay")})
public class Knowledge implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "knowledge_id")
    private Integer knowledgeId;
    @Basic(optional = false)
    @Column(name = "knowledge_date")
    @Temporal(TemporalType.DATE)
    private Date knowledgeDate;
    @Basic(optional = false)
    @Column(name = "knowledge_version")
    private int knowledgeVersion;
    @Basic(optional = false)
    @Column(name = "knowledge_content")
    private String knowledgeContent;
    @Basic(optional = false)
    @Column(name = "knowledge_display")
    private int knowledgeDisplay;
    @JoinColumn(name = "user_id", referencedColumnName = "user_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private User user;
    @JoinColumn(name = "kti_id", referencedColumnName = "kti_id")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private KnowledgeTitleItem knowledgeTitleItem;

    public Knowledge() {
    }

    public Knowledge(Integer knowledgeId) {
        this.knowledgeId = knowledgeId;
    }

    public Knowledge(Integer knowledgeId, Date knowledgeDate, int knowledgeVersion, String knowledgeContent, int knowledgeDisplay) {
        this.knowledgeId = knowledgeId;
        this.knowledgeDate = knowledgeDate;
        this.knowledgeVersion = knowledgeVersion;
        this.knowledgeContent = knowledgeContent;
        this.knowledgeDisplay = knowledgeDisplay;
    }

    public Integer getKnowledgeId() {
        return knowledgeId;
    }

    public void setKnowledgeId(Integer knowledgeId) {
        this.knowledgeId = knowledgeId;
    }

    public Date getKnowledgeDate() {
        return knowledgeDate;
    }

    public void setKnowledgeDate(Date knowledgeDate) {
        this.knowledgeDate = knowledgeDate;
    }

    public int getKnowledgeVersion() {
        return knowledgeVersion;
    }

    public void setKnowledgeVersion(int knowledgeVersion) {
        this.knowledgeVersion = knowledgeVersion;
    }

    public String getKnowledgeContent() {
        return knowledgeContent;
    }

    public void setKnowledgeContent(String knowledgeContent) {
        this.knowledgeContent = knowledgeContent;
    }

    public int getKnowledgeDisplay() {
        return knowledgeDisplay;
    }

    public void setKnowledgeDisplay(int knowledgeDisplay) {
        this.knowledgeDisplay = knowledgeDisplay;
    }

    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    public KnowledgeTitleItem getKnowledgeTitleItem() {
        return knowledgeTitleItem;
    }

    public void setKnowledgeTitleItem(KnowledgeTitleItem knowledgeTitleItem) {
        this.knowledgeTitleItem = knowledgeTitleItem;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (knowledgeId != null ? knowledgeId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Knowledge)) {
            return false;
        }
        Knowledge other = (Knowledge) object;
        if ((this.knowledgeId == null && other.knowledgeId != null) || (this.knowledgeId != null && !this.knowledgeId.equals(other.knowledgeId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ylystudio.pms.ejb.entity.Knowledge[knowledgeId=" + knowledgeId + "]";
    }

}
